
#终极目标
#TARGET := rkFB$(shell date +%Y-%m-%d_%H_%M_%S)
#TARGET := rkFB$(shell date +%S)
TARGET := rkwav


#源文件目录
SRC_DIR := .

rk_lib_dir:=/opt/rv1108_lib_1.4 

armlinux := /opt/rv1108_toolschain/usr/bin/arm-linux-
#编译参数
C_FLAGS := -Wall -O2 
C_FLAGS := -I/opt/rv1108_lib_1.4/include -I/opt/rv1108_lib_1.4/include/rk_fb 
C_FLAGS += $(patsubst %, -I%, $(SRC_DIR))


#链接参数
LD_FLAGS := -L/opt/rv1108_lib_1.4/lib
LD_LIB := -lm -lsalsa

#编译、链接命令
COMPILE_CMD := $(armlinux)gcc $(C_FLAGS) $(CFLAGS) -c
LINK_CMD := $(armlinux)gcc $(LD_FLAGS)


SOURCES := $(foreach dir, $(SRC_DIR), $(wildcard $(dir)/*.c))
HEADERS := $(foreach dir, $(SRC_DIR), $(wildcard $(dir)/*.h))
OBJ := $(SOURCES:%.c=%.o)


.PHONY: clean 


#链接
all: $(TARGET)

$(TARGET): $(OBJ) 
	@echo 
	@echo Linking...
	@echo ---------
	@echo Linking $@ form $^..
	@$(LINK_CMD) -o $@ $^ $(LD_LIB)
	@echo
	@echo 编译成功...
	@echo ---------
	@echo -  输出路径:  `pwd`
	@echo -  输出文件:  $(TARGET)
	@echo -  编译时间:  `date`
	@echo ---------
	@echo 
	@mv $(TARGET) /nfsboot
	@rm $(OBJ)


#编译
$(OBJ): %.o: %.c $(HEADERS)
	@echo Compiling $@ form $<..
	@$(COMPILE_CMD) -o $@ $<


#清理
clean:
	@echo Removing generated files...
	@-$(RM) -rf $(OBJ) 
